package com.vogue.pay.vo;

import lombok.Data;

@Data
public class ResultVo<T> {
    /**
     * 状态码.
     */
    private Integer code;
    /**
     * 数据条数
     */
    private Long count;

    /**
     * 提示信息.
     */
    private String msg;

    /**
     * 具体内容.
     * <p>
     * 属性为 空（""） 或者为 NULL 都不序列化
     */
    private T data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static ResultVo success(Long count,Object object) {
        ResultVo resultVO = new ResultVo();
        resultVO.setData(object);
        resultVO.setCode(0);
        resultVO.setCount(count);
        resultVO.setMsg("成功");
        return resultVO;
    }

    public static ResultVo success(Object object) {
        ResultVo resultVO = new ResultVo();
        resultVO.setData(object);
        resultVO.setCode(0);
        resultVO.setCount(1L);
        resultVO.setMsg("成功");
        return resultVO;
    }

    public static ResultVo<Void> success() {
        return success(null);
    }

    public static ResultVo<Void> success(Integer code, String msg) {
        ResultVo<Void> resultVO = new ResultVo<>();
        resultVO.setCode(code);
        resultVO.setCount(1L);
        resultVO.setMsg(msg);
        return resultVO;
    }

    public static ResultVo<Void> error(Integer code, String msg) {
        ResultVo<Void> resultVO = new ResultVo<>();
        resultVO.setCode(code);
        resultVO.setCount(1L);
        resultVO.setMsg(msg);
        return resultVO;
    }

}
